package es.acm.calendario
{
	import spark.components.Label;
	import spark.components.SkinnableContainer;
	import spark.layouts.HorizontalLayout;
	
	public class HeaderWeek extends SkinnableContainer
	{
		public var dayNames:Array;
		
		public function HeaderWeek()
		{
			super();
			var weekLayout:HorizontalLayout = new HorizontalLayout();
			weekLayout.gap = 0;
			weekLayout.horizontalAlign = 'center';
			weekLayout.verticalAlign = 'bottom';
			layout = weekLayout;
		}
		
		override protected function createChildren():void {
			super.createChildren();
			
			for each(var item:String in dayNames) {
				var it:Label=new Label();
				it.text=item;
				it.percentWidth=100;
				it.setStyle('textAlign','center');
				addElement(it);
			}
		}
		
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
			super.updateDisplayList(unscaledWidth, unscaledHeight);
			
			if (numElements > 0) {
				for (var i:int=0; i<numElements;i++) {
					var item:Label = getElementAt(i) as Label;
					item.text = dayNames[i];
				}
			}
		}
		
		override protected function commitProperties():void {
			super.commitProperties();
			
			invalidateDisplayList();
		}
	}
}